package com.ruitu.mall_98_2.mvp.presenter;

import com.beanu.arad.utils.ToastUtils;
import com.ruitu.mall_98_2.mvp.contract.BalanceContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.SubscriberImpl;

public class BalancePresenter extends BalanceContract.Presenter {
    @Override
    public void getBalance(String accountId) {
        mModel.getBalance(accountId)
                .subscribe(new SubscriberImpl<BaseResult<String>>() {
                    @Override
                    public void onError(Throwable e) {
                        mView.hideProgress();
                        ToastUtils.showShort("获取余额失败");
                    }

                    @Override
                    public void onNext(BaseResult<String> stringBaseResult) {
                        mView.hideProgress();
                        if (stringBaseResult.isSuccess()) {
                            mView.setData(stringBaseResult.getData()+"");
                        } else {
                            ToastUtils.showShort(stringBaseResult.getMsg());
                        }
                    }
                });
    }

}
